package com.ruoyi.project.hissystem.conterllor;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.domain.server.Sys;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.hissystem.domain.SysExamCost;
import com.ruoyi.project.hissystem.service.ISysExamCostService;
import com.ruoyi.project.system.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/*查询费用*/
@Controller
@RequestMapping("/system/money")
public class SysExamCostController extends BaseController {
    @Autowired
    private ISysExamCostService iSysExamCostService;
    @PreAuthorize("@ss.hasPermi('system:money:list')")
    @GetMapping("/index")
    @ResponseBody
    public TableDataInfo list(SysExamCost sysExamCost) {
        startPage();
        List<SysExamCost> sysExamCosts = iSysExamCostService.selSysExamCost(sysExamCost);
        return getDataTable(sysExamCosts);
    }


    /**
     * 新增岗位
     */
    @PreAuthorize("@ss.hasPermi('system:money:add')")
    @Log(title = "费用项目管理", businessType = BusinessType.INSERT)
    @PostMapping("add")
    @ResponseBody
    public AjaxResult add(@RequestBody SysExamCost sysExamCost)
    {

        sysExamCost.setCreateBy(SecurityUtils.getUsername());
        System.out.println(iSysExamCostService.insSysExamCost(sysExamCost));
        return toAjax(iSysExamCostService.insSysExamCost(sysExamCost));
    }

    /*根据id查询*/

    @PreAuthorize("@ss.hasPermi('system:money:query')")
    @GetMapping(value = "/{examid}")
    @ResponseBody
    public AjaxResult getInfo(@PathVariable int examid)
    {
        return AjaxResult.success(iSysExamCostService.selSysExamCostOne(examid));
    }

    /*修改费用*/
    @PreAuthorize("@ss.hasPermi('system:money:edit')")
    @Log(title = "费用项目管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ResponseBody
    public AjaxResult edit(@RequestBody SysExamCost sysExamCost)
    {

        sysExamCost.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(iSysExamCostService.upSysExamCost(sysExamCost));
    }

    /*删除费用项目信息*/

    @PreAuthorize("@ss.hasPermi('system:money:remove')")
    @Log(title = "费用项目管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{examids}")
    @ResponseBody
    public AjaxResult remove(@PathVariable int[] examids)
    {
        return toAjax(iSysExamCostService.delSysExamCost(examids));
    }

}
